package org.yenn.pattern.aliyun.j2ee.servicelocator;

import org.yenn.pattern.aliyun.j2ee.servicelocator.impl.Service1;
import org.yenn.pattern.aliyun.j2ee.servicelocator.impl.Service2;

/**
 * @Author: yerenyun
 * @Description: 步骤 3 为 JNDI 查询创建 InitialContext。
 */
public class InitialContext {
    public Object lookup(String jndiName) {
        if (jndiName.equalsIgnoreCase("SERVICE1")) {
            System.out.println("Looking up and creating a new Service1 object");
            return new Service1();
        } else if (jndiName.equalsIgnoreCase("SERVICE2")) {
            System.out.println("Looking up and creating a new Service2 object");
            return new Service2();
        }
        return null;
    }
}